#include "testApp.h"

//--------------------------------------------------------------
void testApp::setup(){
	
    pos.set(ofGetWidth()/2, ofGetHeight()/2);
    
    anim = walkAnimation;
    
    anim.frame_duration = 100;
    anim.index = 16;
    
    spriteRenderer = new ofxSpriteSheetRenderer(1, 10000, 0, 32); //declare a new renderer with 1 layer, 10000 tiles per layer, default layer of 0, tile size of 32

    spriteRenderer->loadTexture("spriteSheetExample.png", 256, GL_NEAREST); // load the spriteSheetExample.png texture of size 256x256 into the sprite sheet. set it's scale mode to nearest since it's pixel art

    
	ofEnableAlphaBlending(); // turn on alpha blending. important!
    
    
}

//--------------------------------------------------------------
void testApp::update(){
    
    pos.y += 0.1;
    
    spriteRenderer->clear(); // clear the sheet
	spriteRenderer->update(ofGetElapsedTimeMillis()); //update the time in the renderer, this is necessary for animations to advance
    
    spriteRenderer->addCenteredTile(&anim, pos.x, pos.y); // add them to the sprite renderer (add their animation at their position, there are a lot more options for what could happen here, scale, tint, rotation, etc, but the animation, x and y are the only variables that are required)


}

//--------------------------------------------------------------
void testApp::draw(){
	
	spriteRenderer->draw(); //draw the sprites!
}

//--------------------------------------------------------------
void testApp::keyPressed(int key){
	
}

//--------------------------------------------------------------
void testApp::keyReleased(int key){

}

//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){

}

//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){

}

//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
	
}

//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){

}

//--------------------------------------------------------------
void testApp::windowResized(int w, int h){

}

